<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //计算阶乘
        var n = Number(prompt('请输入数字'));
        //累乘器 从1开始 如果要从0开始 0乘以任何数字都为0
        var result = 1;
        //倒着遍历 计算阶乘
        for (var i = n; i >= 1; i--) {
            result *= i;
        }

        alert(result);
    </script>

</body>

</html>